<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件</title>
    <script src="scripts/jquery-3.4.1.min.js"></script>
    <script src="scripts/vue.js"></script>
</head>
<body>
    <div id="app">
        <hello-com v-if="isShow"></hello-com>
    </div>

    <script>
          //定义组件
          let helloCom = Vue.component("hello-com",{
            template:'<div><p>{{content}}</p><button @click="ChangeData">修改数据</button></div>',
            data:function(){
                return {
                    content:"hello component"
                }
            },
            methods:{
                ChangeData:function(){
                    this.content='hello xlb'
                }
            },
            beforeCreate:function() {  //创造之前
                console.log("beforeCreate")
             
            },
            created:function() {
                console.log("created")             
            },
            beforeMount:function(){
                //渲染之前，根据数据生成的DOM对象是获取不到的
                console.log('beforeMount')                
            },
            mounted:function(){
                //渲染之后，可以数据生成的DOM对象
                console.log('Mounted')                
            },
            beforeUpdate:function(){
                //数据更改但内容未更改之前
                console.log('beforeUpdate')             
            },
            updated:function(){
                //内容已更新
                console.log('updated')
            },
            beforeDestroy:function(){
                //应用销毁之前
                console.log('beforeDestroy')
            },
            destroyed:function(){
                //应用销毁之后
                console.log('destroyed')
            }
        })
    
        let app=new Vue({
            el:"#app",
            data:{
                isShow:true
            },
            methods:{
                clickEvent:function(){

                }
            }
        })

      
    </script>
</body>
</html>